package org.example;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.checksum.crc16.CRC16CCITTFalse;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.sun.jdi.IntegerType;
import jdk.dynalink.beans.StaticClass;
import org.junit.Test;

import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.*;

public class example {
//    @Test
//    public void test() {
//        String a="";
//        String b=null;
//        String c="a";
//        String d="  ";
//        System.out.println(a.isEmpty()+" "+a.length()+" "+a.equals("")+" "+a.equals(" ")+" "+StrUtil.isBlank(a)+" "+StrUtil.isNotBlank(a)+" "+StrUtil.isEmpty(a));
//        //System.out.println(b.isEmpty()+" "+b.length()+" "+b.equals("")+" "+b.equals(" ")+" "+StrUtil.isBlank(b)+" "+StrUtil.isNotBlank(b)+" "+StrUtil.isEmpty(b));
//        System.out.println(c.isEmpty()+" "+c.length()+" "+c.equals("")+" "+c.equals(" ")+" "+StrUtil.isBlank(c)+" "+StrUtil.isNotBlank(c)+" "+StrUtil.isEmpty(c));
//        System.out.println(d.isEmpty()+" "+d.length()+" "+d.equals("")+" "+d.equals(" ")+" "+StrUtil.isBlank(d)+" "+StrUtil.isNotBlank(d)+" "+StrUtil.isEmpty(d));
//    }
    @Test
    public void test2() {
        Date date=new Date(System.currentTimeMillis());                 //时间戳转化为Date对象
        System.out.println(date);

        LocalDateTime localDateTime = LocalDateTime.now();              //localHostTime的格式化
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String string = localDateTime.format(dateTimeFormatter);
        System.out.println(string);

        LocalDateTime startTime = LocalDateTime.of(2025, 1, 23, 10, 0, 0);      //localDateTime计算时间差
        LocalDateTime endTime = LocalDateTime.of(2025, 1, 23, 12, 0, 0);
        Duration duration=Duration.between(startTime, endTime);
        System.out.println(duration.getSeconds()+" "+duration.toMinutes()+" "+duration.toHours());

        ZonedDateTime zonedDateTime = LocalDateTime.now().atZone(ZoneId.systemDefault());                   //localhostTime转化为时间戳
        Instant instant = zonedDateTime.toInstant();
        long timestampsecond=instant.getEpochSecond();
        System.out.println(timestampsecond);

        Instant instant1 = instant.ofEpochSecond(timestampsecond);                                          //时间戳转化为LocalHostTime对象
        LocalDateTime localDateTime1 = LocalDateTime.ofInstant(instant1, ZoneId.systemDefault());
        System.out.println(localDateTime1);

        ZonedDateTime zonedDateTime1 = localDateTime.now().atZone(ZoneId.systemDefault());                  //lcoalDateTime转化为Date
        Instant instant2 = zonedDateTime1.toInstant();
        Date date1=Date.from(instant2);
        System.out.println(date1);
    }
    @Test
    public void isValid() {
        String s = "()";
        int n=s.length();
        if(n%2!=0)
            System.out.println(false);
        int i=0;
        int j=0;
        boolean b=false;
        for(i=0;i<s.length();i++){
            if(s.charAt(i)=='('){
                j=s.indexOf(')');
                if(j==-1){
                    b=false;
                    break;
                }
                if(j-i==1||j-i==-1||(j-i)%2==1){
                    b=true;
                    s.replace(")","");
                    continue;
                }
            }
            if(s.charAt(i)=='['){
                j=s.indexOf(']');
                if(j==-1){
                    b=false;
                    break;
                }
                if(j-i==1||j-i==-1||(j-i)%2==1){
                    b=true;
                    s.replace("]","");
                    continue;
                }
            }
            if(s.charAt(i)=='{'){
                j=s.indexOf('}');
                System.out.println(i+".."+j);
                if(j==-1){
                    b=false;
                    break;
                }
                if(j<i){
                    b=false;
                    break;
                }
                if(j-i==1||j-i==-1||(j-i)%2==1){
                    b=true;
                    s.replace("}","");
                    continue;
                }
            }
            if(s.indexOf(')')!=-1||s.indexOf(']')!=-1||s.indexOf( "}")!=-1){
                b=false;
                break;
            }
            break;
        }
        System.out.println(b);
    }
}